/**
 * 
 */
package com.sys.console.business.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.sys.console.business.SysMonitorService;
import com.sys.console.common.ConstantSys;
import com.sys.console.mapper.SysMonitorMapper;
import com.sys.console.pojo.SysMonitor;

/**
 * @author zxp
 *
 */
@Service
public class SysMonitorServiceImpl implements SysMonitorService {

	@Autowired SysMonitorMapper sysMonitorMapper;
	@Override
	public SysMonitor selectByPrimaryKey(String id,HttpServletRequest request) throws Exception {
		SysMonitor sysmon = ConstantSys.sysMon;
		if(sysmon == null || !StringUtils.hasText(sysmon.getId())){
			sysmon = sysMonitorMapper.selectByPrimaryKey(id);
			ConstantSys.sysMon = sysmon;
		}
		return sysmon;
	}
	@Override
	public int saveOrUpdate(SysMonitor record,HttpServletRequest request) throws Exception {
		int suc = 0;
		if(record!=null && StringUtils.hasText(record.getId())){
			suc = sysMonitorMapper.updateByPrimaryKeySelective(record);
			if(suc >0){
				ConstantSys.sysMon = record;
			}
			return suc;
		}
		suc = sysMonitorMapper.insert(record);
		if(suc >0){
			ConstantSys.sysMon = record;
		}
		return suc;
	}


}
